package sctu.edu.java.year2016.team01.chenhong.day20160614.chapter12_3;

import javax.swing.*;

import java.io.*;

import java.util.Scanner;

/**
 * Created by Administrator on 2016/6/15.
 *  实现当用户输入姓名和密码时，将每一个姓名和密码加在文件中。。
 */
public class Entering extends JFrame {


    public void imput(String name, int password) {

        File file = new File("F:\\zuoye\\information.txt");

        Writer out = null;
        try {
            out = new FileWriter(file, true);

            String info = "姓名：" + name + "   密码：" + password;

            out.write(info.toCharArray());
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }


    public static void main(String[] args) throws IOException {

        System.out.println("请姓名和密码：");


        Scanner scan = new Scanner(System.in);

        String name = scan.nextLine();

        int password = scan.nextInt();

        Entering entering = new Entering();
        entering.imput(name, password);

    }
}
